package com.task.vo;

import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

@Data
@NoArgsConstructor
@AllArgsConstructor
public class ResultVo<T> {
    private int code;
    private String msg;
    private T data;
    private static final int SUCCESS_CODE = 200;
    private static final String SUCCESS_MSG = "SUCCESS";
    private static final int ERROR_CODE = 500;
    private static final String ERROR_MSG = "ERROR";
    private static final int NO_AUTH_CODE = 999;


    public static <T> ResultVo<T> success(T data){
        return new ResultVo<>(SUCCESS_CODE,SUCCESS_MSG,data);
    }
    public static <T> ResultVo<T> errors(T data){
        return new ResultVo<>(ERROR_CODE,ERROR_MSG,data);
    }
    public static ResultVo failed(String msg){
        return new ResultVo(ERROR_CODE,msg,"");
    }
    public static ResultVo noAuth(String msg){
        return new ResultVo(NO_AUTH_CODE,msg,"");
    }
}
